<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>api测试</title>
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>

<body>
  <script>
    function* apiTest() {
      const url = 'https://api.github.com/users/github'
      const res = yield axios.get(url)
      console.log(res)
    }
    const g = apiTest()
    const res = g.next()
    res.value.then(res => {
      return res
    }).then(res => {
      /*   把返回结果又丢进去,这里这个网络请求看着的确是同步代码,
            打印的res确实在后面执行了,但是感觉很奇怪 */
      g.next(res)
    })
    // 说实话,学习时感觉这个函数在请求数据是看着是舒服但是总感觉用起来挺奇怪
  </script>
</body>

</html>